<!DOCTYPE>
<html>
<head>
<script type="text/javascript">
window.onload = function() {
	document.getElementById('boton').onclick = sendRequest;

	function sendRequest(){
		var request;
		
		if(window.XMLHttpRequest){
			// Standard browsers
			request = new XMLHttpRequest();
		}
		else if(window.ActiveXObject){
			// old browsers
			request = new ActiveXObject('Microsoft.XMLHTTP');
		}

		request.onreadystatechange = holaMundo;

		request.open('GET','https://www.google.es');
		request.send(null);

		function holaMundo(){
			if(peticion.readyState==4){
				if(peticion.status==200){
					alert(peticion.responseText);
				}
			}
			else{
				document.getElementById('result').innerHTML = 'Loading...';
			}
		}
	}
};
</script>
</head>
<body>
	<input type="button" id="boton" value="Enviar peticion" />
	<p id="result"></p>
</body>
</html>